<template>
  <div class="rightCommonWrapper" :class="{ isShrink: state.isShrink }">
    <section class="content">
      <GateControl />
      <div class="monitoring">
        <WaterMonitoring />
        <FlowMonitoring />
      </div>
      <SoilMonitoring />
    </section>
    <slot></slot>
    <div class="shrinkBtn" @click="handleClickShrink">
      <MenuUnfoldOutlined :rotate="state.iconRotate" />
    </div>
  </div>
</template>

<script lang="ts" setup>
  import { reactive, watch } from "vue";
  import { MenuUnfoldOutlined } from "@ant-design/icons-vue";
  import WaterMonitoring from "./WaterMonitoring";
  import FlowMonitoring from "./FlowMonitoring";
  import SoilMonitoring from "./SoilMonitoring";
  import GateControl from "./GateControl";

  defineOptions({ name: "RightCommon" });

  const props = defineProps({
    isCollapse: { type: Boolean },
  });

  const state = reactive({
    isShrink: false,
    iconRotate: 0,
  });

  // 一键收起侧边栏
  watch(
    () => props.isCollapse,
    (val) => {
      state.isShrink = val;
      state.iconRotate = val ? 180 : 0;
    }
  );

  const handleClickShrink = () => {
    state.isShrink = !state.isShrink;
    state.iconRotate = state.isShrink ? 180 : 0;
  };
</script>

<style lang="less" rel="stylesheet/less" scoped>
  .rightCommonWrapper {
    width: 626px;
    height: 978px;
    position: absolute;
    top: 60px;
    right: 60px;
    z-index: 200;
    transition: all 0.5s;
    transform: translateX(0px);
    section.content {
      width: 100%;
      height: 100%;
      // backdrop-filter: blur(10px);
      display: grid;
      grid-template-rows: minmax(300px, 30%) minmax(360px, 34%) minmax(300px, 30%);
      grid-row-gap: 20px;
      position: relative;
      .monitoring {
        width: 100%;
        display: flex;
        justify-content: space-between;
        ::v-deep(.titleName) {
          width: 60% !important;
        };
      }
    }
    /* .shrinkBtn {
        width: 28px;
        height: 28px;
        background: rgba(50, 120, 160, 0.6);
        color: #00A2FF;
        border-radius: 4px;
        position: absolute;
        top: 20px;
        right: 700px;
        z-index: 100;
        font-size: 18px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        opacity: 0.6;
        transition: all 0.5s;
        transform: translateX(0px);
        backdrop-filter: blur(8px);
        &:hover {
          background: rgba(50, 120, 160, 0.8);
          opacity: 1;
        }
      } */
  }
  .isShrink {
    transform: translateX(670px);
  }
</style>
